package com.anrongtec.zcpt.model;

import android.content.Context;

import com.anrongtec.zcpt.utils.MyLocation;
import com.anrongtec.zcpt.utils.Util;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;


/**
 * 接口公共参数
 * @author cxy
 *
 */
public class BaseInfo {

	/** 接口编码 */
	String busCode;
	
	/** 应用类型 */
	String appType;
	
	/** 当前应用版本 */
	int appVersion;
	
	/** 应用系统信息 */
	String appOs;
	
	/** 设备IMEI */
	String imei;
	
	/** 设备IMSI */
	String imsi;
	
	/** 设备序列号 */
	String deviceSN;
	
	/** 设备类型 */
	String deviceType;
	
	/** 网卡MAC地址 */
	String mac;
	
	/** 应用的v4 IP地址 */
	String ip;
	
	/**uuid*/
	String uuid;
	
	/** 经度 */
	String longitude;
	
	/** 纬度 */
	String latitude;
	
	/** 高度 */
	String altitude;

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getBusCode() {
		return busCode;
	}

	public void setBusCode(String busCode) {
		this.busCode = busCode;
	}

	public String getAppType() {
		return appType;
	}

	public void setAppType(String appType) {
		this.appType = appType;
	}

	public int getAppVersion() {
		return appVersion;
	}

	public void setAppVersion(int appVersion) {
		this.appVersion = appVersion;
	}

	public String getAppOs() {
		return appOs;
	}

	public void setAppOs(String appOs) {
		this.appOs = appOs;
	}


	public String getDeviceSN() {
		return deviceSN;
	}

	public void setDeviceSN(String deviceSN) {
		this.deviceSN = deviceSN;
	}

	public String getDeviceType() {
		return deviceType;
	}

	public void setDeviceType(String deviceType) {
		this.deviceType = deviceType;
	}


	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}

	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}

	public String getAltitude() {
		return altitude;
	}

	public void setAltitude(String altitude) {
		this.altitude = altitude;
	}
	
	public String getImei() {
		return imei;
	}

	public void setImei(String imei) {
		this.imei = imei;
	}

	public String getImsi() {
		return imsi;
	}

	public void setImsi(String imsi) {
		this.imsi = imsi;
	}

	public String getMac() {
		return mac;
	}

	public void setMac(String mac) {
		this.mac = mac;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

	private static BaseInfo instance;
	
	private BaseInfo() {
		resetInstance();
	}
	
	private static Context context;
	
	/**
	 * 获取实例
	 * @return
	 */
	public static synchronized BaseInfo getInstance(Context context){
		if (instance == null) {
			instance = new BaseInfo();
		}
		return instance;
	}
	
	/**
	 * 重置实例
	 */
	public void resetInstance(){
		appType = null;
		appVersion = Util.getVersionCode(context);
		appOs = Util.getAppOS();
		imei = Util.getImei(context);
		imsi = Util.getImsi(context);
		deviceSN = Util.getDeviceSN(context);
		deviceType = "Android";
		mac = Util.getMac(context);
		ip = Util.getIP(context);
		uuid = UUID.randomUUID().toString();
		longitude = MyLocation.getLongitude();
		latitude = MyLocation.getLatitude();
		altitude = MyLocation.getAltitude();
	}

	/**
	 * 获取map格式公共参数
	 * @return
	 */
	public Map<String, Object> getPublicParameter(){
		
		Map<String, Object> map = new HashMap<String, Object>();
//		map.put("busCode", getBusCode());
		map.put("appType", getAppType());
		map.put("appVersion", getAppVersion());
		map.put("appOs", getAppOs());
		map.put("IMEI", getImei());
		map.put("IMSI", getImsi());
		map.put("deviceSN", getDeviceSN());
		map.put("deviceType", getDeviceType());
		map.put("mac", getMac());
		map.put("ip", getIp());
		map.put("uuid", getUuid());
		map.put("longitude", getLongitude());
		map.put("latitude", getLatitude());
		map.put("altitude", getAltitude());
		
		return map;
	}
	
}
